<%@ page contentType='text/html;charset=utf-8' %>

<%@ page import="java.sql.DriverManager" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.PreparedStatement" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="java.sql.SQLException" %>


<html>
<head>
<title>list</title>
<meta http-equiv='Content-Type' content='text/html;charset=utf-8'>
<link rel='stylesheet' type='text/css' href='../images/common.css'>
</head>

<body bgcolor='#ffffff' topmargin='5' rightmargin='0' leftmargin='5' bottommargin='10'>

<table width='750px' border='0' cellpadding='0' cellspacing='0' align='center'>
<tr>
	<td height='23' bgcolor='#f0f0f0' align='right'></td>
</tr>
<tr>
	<td bgcolor='#ffffff' style='padding:20'>
		<table width='100%' cellpadding='0' cellspacing='0' border='0'>
		<tr>
			<td class='stab_bot' colspan='3'></td>
		</tr>
		<tr>
			<td class='stab_left'></td>
			<td class='stab_mid' style='padding:5px 5px 0px 5px'> 	
<!-- 검색 부분 -->
				<form action='' method='post'>
				<table border='0' cellpadding='0' cellspacing='0' width='100%'>
				<tr>
					<td></td>
					<td height='25' align='right'>
						<select name='searchKey' class='form' align='absmiddle'>
							<option value='all'>전체</option>
							<option value='subject'>제목</option>
							<option value='writer'>이름</option>
							<option value='content'>내용</option>
						</select>
						<input type='text' name='searchWord' size='15' align='absmiddle' class='form'>
						<input type='image' src='../images/btn_search.gif' border='0' align='absmiddle'>
					</td>
				</tr>
				</table>
				</form>
<!-- -->
			</td>
			<td class='stab_right'></td>
		</tr>
		<tr>
			<td class='stab_bot' colspan='3'></td>
		</tr>
		<tr>
			<td height='10' colspan='3'></td>
		</tr>
		</table>

		<table width='100%' border='0' cellpadding='0' cellspacing='0'>
		<tr>
			<td align='center' class='gline'></td>
		</tr>
		<tr>
			<td align='center'>
				<table width='100%' border='0' cellpadding='0' cellspacing='0' class='titlecell'>
				<tr height='25' align='center'>
					<td width='40'>No</td>
					<td>제목</td>
					<td width='100'>이름</td>
					<td width='80'>등록일</td>
					<td width='50'> 조회수</td>
				</tr>
				</table>
			</td>
		</tr>
		<tr>
			<td align='center' class='gline'></td>
		</tr>
		<tr>
			<td height='3'></td>
		</tr>
		</table>
<!-- 행시작 -->
<%
	Connection conn =null;
	ResultSet rs=null;
	PreparedStatement pstmt = null; 

	String driver = "oracle.jdbc.driver.OracleDriver";
	String url = "jdbc:oracle:thin:@localhost:1521:orcl";
	String user = "scott";
	String password = "tiger";

	try{
		Class.forName(driver);
		conn=DriverManager.getConnection(url, user, password);
		String sql = "select seq, subject, writer, to_char(wdate,'RR.MM.DD') wdate, hit, trunc(sysdate - wdate) wgap from board1 order by asc";
		pstmt = conn.prepareStatement(sql);

		rs = pstmt.executeQuery();
		
		while(rs.next()){
			String seq = rs.getString("seq");
			String subject = rs.getString("subject");
			String writer= rs.getString("writer");
			String wdate= rs.getString("wdate");
			String hit= rs.getString("hit");
			String wgap = rs.getInt("wgap") !=0 ? "" : "<img src='../images/ico_n.gif' width='8' height='8' border='0' hspace='3'>"; 
		
%>
		<table width='100%' border='0' cellpadding='0' cellspacing='0'>
		<tr>
			<td height='1'></td>
		</tr>
		<tr>
			<td>
				<table width='100%' border='0' cellpadding='0' cellspacing='0'>
					<tr height='25' onMouseOver="this.className='evencell'" onMouseOut="this.className=''">
						<td width='40' align='center'><%=seq %></td>
						<td>
							<span style='width:370' class='elltxt'>
								<!-- seq를 가지고 view로 넘어가야 한다 -->
								<a href='board_view1.jsp?seq=<%=seq %>'><%=subject %></a>
								<%=wgap %>
							</span>
						</td>
						<td width='100' align='center'><%=writer %></td>
						<td width='80' align='center'><%=wdate %></td>
						<td width='50' align='center'><%=hit %></td>
					</tr>
				</table>
			</td>
		</tr>
		
		<tr>
			<td height='1'></td>
		</tr>
		<tr>
			<td align='center' class='imgline'></td>
		</tr>
		</table>
<!-- 행 끝 -->	
<%
		} //while문 종료
	}catch(ClassNotFoundException e){
	
	}catch(SQLException e){
	
	}finally{
		if(rs != null) rs.close();
		if(pstmt != null) pstmt.close();
		if(conn != null) conn.close();
    }
%>	
		<table width='100%' border='0' cellpadding='0' cellspacing='0'>
		<tr>
			<td width='500' height='30'>&nbsp;</td>
			<td align='right'>
				<a href='board_write1.jsp'><img src='../images/btn_wri.gif' border='0'></a>
			</td>
		</tr>
		</table>
	</td>
</tr>
</table>	


<table width='750px' border='0' cellpadding='0' cellspacing='0' align='center'>
<tr>
	<td height='15' bgcolor='#f0f0f0' style='padding:5' align='center'></td>
</tr>
</table>
	
</body>
</html>
